package com.platform.service;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.platform.cache.J2CacheUtils;
import com.platform.dao.ApiTopicMapper;
import com.platform.dao.ApiUserLevelMapper;
import com.platform.entity.TopicVo;
import com.platform.entity.UserLevelVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service
public class ApiUserLevelService {
    @Autowired
    private ApiUserLevelMapper apiUserLevelMapper;

    public UserLevelVo queryRule() {
        UserLevelVo userLevelEntity = JSONObject.parseObject((String)J2CacheUtils.get("user_level_rule"), new TypeReference<UserLevelVo>(){});;
        if (userLevelEntity == null){
            userLevelEntity = apiUserLevelMapper.queryObject(UserLevelVo.USER_LEVEL_RULE_ID);
            J2CacheUtils.put("user_level_rule", JSONObject.toJSONString(userLevelEntity));
        }
        return userLevelEntity;
    }

}
